<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../css/reset.css">
    <script src="../js/vue.js"></script>
    <style>
        li {
            line-height: 40px;
            text-indent: 16px;
            border: 1px dashed #333;
        }
    </style>
</head>

<body>
    <div id="app">
        <p>
            <button @click="list.sort()">排序</button>
        </p>
        <!-- <ul>
            <li v-for="(item,index) in list" v-if="item % 2 == 0" :key="index">{{item}}</li>
        </ul> -->
        <ul>
            <li v-for="(item,index) in list.filter(v=>v%2==0)" :key="index">{{item}}</li>
        </ul>
    </div>
</body>
<script>
    // 一般情况下,不建议v-for和v-if同时使用, 如果v-for和v-if同时使用 v-for的优先级高于v-if,先将元素重复n次,在逐个判断每个元素是否渲染


    var app = new Vue({
        el: "#app",
        data: {
            list: [1, 4, 7, 2, 5, 8, 3, 6, 9],
        }
    })


</script>

</html>